let geoGfx = require('geoGfxBase');

let GfxOutline = cc.Class({

    extends: geoGfx,
    
    // _shaderName: 'Outline',
    _getShaderName(){
        return 'Outline';
    },

    properties: {
        outlineColor:{
            default:cc.Color.YELLOW,
            tooltip:'边框颜色'
        },
        outlineRatio:{
            default:1.0,
            tooltip:'值越高，边框颜色越集中'
        },
    },

    _preApplyShader(){
        // 记录原始颜色
        this._oldColor = this.sprite.node.color;
    },
    _postApplyShader(){
        var node = this.sprite.node;
        // 启用发光颜色
        node.color = this.outlineColor;
        // 设置
        this.setMaterialParams({
            iResolution: new cc.Vec3(node.width * this.outlineRatio, node.height * this.outlineRatio, 0),
        });
    },
    _postUnapplyShader(){
        // 恢复原有颜色
        this.sprite.node.color = this._oldColor;
    }
});

module.exports = GfxOutline;